<template>
  <div class="search-table-wrap">
    <div class="search-book" v-for="(book,index) in data" :key="index" @click="onClick(index)">
      <div class="search-table-img">
        <ImageView
          :src=book.cover
        />
      </div>
      <div class="book-info">
        <div class="book-title">{{book.title}}</div>
        <div class="book-bottom">
          <div class="book-author">{{book.author}}</div>
          <div class="book-category">{{book.categoryText}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import ImageView from "../base/ImageView.vue";

  export default {
    components: {
      ImageView
    },
    props: {
      data: []
    },
    methods: {
      onClick(index) {
        let fileName = this.data[index].fileName;
        this.$router.push({
          path : '/pages/detail/main',
         query : {
           fileName
         },
        })
      }
    }
  };
</script>

<style lang="less" scoped>
  .search-table-wrap {
    .search-book {
      display: flex;
      padding: 14px 16px;
      box-sizing: border-box;
      .search-table-img {
        width: 47px;
        height: 68.5px;
        margin-right: 15px;
      }
      .book-info {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 2px 0 5px 0;
        width: 80%;

        .book-title {
          width: 100%;
          font-size: 16px;
          color: #333333;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          font-family: PingFangSC-Regular;
        }

        .book-bottom {
          .book-author {
            font-size: 13px;
            color: rgba(0, 0, 0, 0.65);
          }

          .book-category {
            font-size: 13px;
            color: rgba(0, 0, 0, 0.45);
          }
        }
      }
    }
  }
</style>
